#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll t; cin >> t;
	while (t--){
		ll l, r; cin >> l >> r;
		if (r - l >= 10) {
			cout << 0 << '\n';
			continue;
		}
		ll ans = 1;
		for (int i = l; i <= r; i++) {
			ll tmp = i;
			while (tmp){
				ans = ans * (tmp % 10);
				ans %= 1000000007;
				tmp /= 10;
			}
		}
		cout << ans << '\n';
	}
	return 0;
}